import React, { useEffect, useState } from 'react'

export default function EffectHookDemo() {
  const [count, setCount] = useState(10);

  //dom渲染好之后触发 此后不管更新还是渲染 都会触发
  useEffect(() => {
    if(count === 0) {
      setCount(Math.random() + 2000)  //从0变成200有不断闪烁效果
    }
  }, [count])
  
  return (
    <div>
      <h2>当前计数：{count}</h2>
      <button onClick={e => setCount(0)}>修改</button>
    </div>
  )
}
